const Mock = require('mockjs')

const data = Mock.mock({
  'items|20': [{
    id: '@id',
    roleName: '@sentence(1, 5)',
    update: 'name',
    create: 'name',
    lastTime: '@datetime',
    creationTime: '@datetime'
  }]
})

module.exports = [
  {
    url: '/vue-admin-template/role/list',
    type: 'get',
    response: config => {
      const items = data.items
      return {
        code: 0,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  }, {
    url: '/vue-admin-template/role/getRoleInfo',
    type: 'get',
    response: config => {
      const data = Mock.mock({
        id: '@id',
        roleName: '@sentence(1, 5)',
        update: 'name',
        create: 'name',
        lastTime: '@datetime',
        creationTime: '@datetime'
      })
      return {
        code: 0,
        data
      }
    }
  }, {
    url: '/vue-admin-template/role/saveRole',
    type: 'post',
    response: config => {
      return {
        code: 0,
        data: true,
        message: 'success'
      }
    }
  }, {
    url: '/vue-admin-template/role/getRoleMenu',
    type: 'get',
    response: config => {
      return {
        code: 0,
        data: ['A1.1', 'A1.3.1', 'A2.1']
      }
    }
  }, {
    url: '/vue-admin-template/role/saveMenu',
    type: 'post',
    response: config => {
      return {
        code: 0,
        data: true
      }
    }
  }
]

